const initState = {
  isLogin: sessionStorage.getItem('isLogin'),
  user: JSON.parse(sessionStorage.getItem('loginUser')),
}
export default (state = initState, action) => {
  switch (action.type) {
    case 'LOGIN_SUCCESS':
      return {
        ...state,
        isLogin: true,
        user: action.payload.data,
      };
    case 'LOGOUT':
      return {
        ...state,
        isLogin: false,
        user: null,
      };
    default:
      return state;
  }
};
export const login = (params) => {
  return {
    type: 'LOGIN',
    payload: params,
  };
}

export const logout = (params = {}) => ({
  type: 'LOGOUT',
  payload: params,
});
